function handlePageLoadSuccess () {

  if (location.href.indexOf('www.8btxt.com/classtop') > -1) {
    debugger
    let aLinkInx = Number(localStorage.getItem('aLinkInx')) || 0
    let list = document.querySelectorAll('div.rankdetail > div.rankdetailleft > a')
    let imgList = document.querySelectorAll('div.rankdetail > div.rankdetailleft > a img')
    for (let index = 0; index < imgList.length; index++) {
      let x = imgList[index].title
      console.log(x)
    }

    function clickNext () {
      if (aLinkInx < list.length) {
        console.log('当前下标是' + aLinkInx + '，当前书籍名为： ' + imgList[aLinkInx].title)
        window.open(list[aLinkInx].href, '_self')
        aLinkInx++
        localStorage.setItem('aLinkInx', aLinkInx)
        setTimeout(clickNext, 1000)
      } else {
        let pageNo = Number(localStorage.getItem('pageNo')) || 1
        pageNo++
        localStorage.setItem('pageNo', pageNo)
        localStorage.setItem('aLinkInx', 0)
        let url = `http://www.8btxt.com/classtop/3-0-${pageNo}.html`
        window.open(url, '_self')
      }
    }
    clickNext()
  }

  if (location.href.indexOf('www.8btxt.com/wanben') > -1) {
    setTimeout(() => {
      if (document.querySelectorAll('.item ul li.bd a').length > 0) {
        let url_x = document.querySelectorAll('.item ul li.bd a')[0].href
        debugger
        const downloadLink = document.createElement('a')
        downloadLink.href = url_x
        downloadLink.download = 'custom_file_name.pdf'
        document.body.appendChild(downloadLink)
        downloadLink.click()
        document.body.removeChild(downloadLink)
        setTimeout(() => {
          let pageNo = Number(localStorage.getItem('pageNo')) || 1
          let url = `http://www.8btxt.com/classtop/3-0-${pageNo}.html`
          window.open(url, '_self')
        }, 1000)
      }
    }, 2000)
  }
}

handlePageLoadSuccess()
